"""
@Author  : 康帅
@Time    : 2021/6/16 15:45
@Function: 
"""

import functools

"""
偏函数不仅仅可用于独立函数，它可与任何可调用对象一起工作。
"""


class MyClass:
    """Demonstration class for functools"""

    def __call__(self, e, f=6):
        """Docstring for MyClass.__call__"""

        print('called object with:', (self, e, f))


def show_details(name, f):
    """Show details of a callable object"""

    print(f'{name}')
    print(f'object:{f}')
    print('__name__:', end=' ')
    try:
        print(f.__name__)
    except AttributeError:
        print('no __name__')
    print('__doc__', repr(f.__doc__))
    return


o = MyClass()
show_details('instance', o)
o('e goes here')
print()

p = functools.partial(o, e='default for e', f=8)
functools.update_wrapper(p, o)
show_details('instance wrapper', p)
p()
